<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        //创建一个初始化表达式
        // var i = 0;
        //
        // //创建循环和条件表达式
        // while (i < 5){
        //
        //     console.log('hello');
        //     //更新表达式
        //     i++;
        // }

        var age = prompt('请输入狗狗的年龄');

        while (isNaN(age) || age < 0) {
            age = prompt('请输入正确的年龄');
        }

        var likePersonAge;

        if (age <= 2) {
            likePersonAge = age * 10.5;
        } else {
            likePersonAge = 21 + (age - 2) * 4;
        }
        alert('狗狗的年龄相当于人的年龄：' + likePersonAge + '岁');


        //假设存款的年利率为5%，1000元存几年能变成5000元

        // var money = 1000;
        // var year = 0;
        // while (money <= 5000){
        //     money *= 1.05;
        //     year++;
        // }
        // alert( year + '年' );

    </script>
</head>
<body>

</body>
</html>